using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CommonUtils;

namespace ShellAnywhere.Model
{
	public class HashTreeNode<_Key, _Data>
	{
		#region ctors
		public HashTreeNode(HashTreeNode<_Key, _Data> parent)
		{
			Parent = parent;
			Data = default(_Data);
			Children = new Dictionary<_Key, HashTreeNode<_Key, _Data> >();
		}
		public HashTreeNode(HashTreeNode<_Key, _Data> parent, _Data data)
		{
			Parent = parent;
			Data = data;
			Children = new Dictionary<_Key, HashTreeNode<_Key, _Data> >();
		}
		#endregion ctors

		#region properties
		public HashTreeNode<_Key, _Data> Parent { get; set; }
		public _Data Data { get; set; }
		public Dictionary<_Key, HashTreeNode<_Key, _Data> > Children { get; set; }
		#endregion properties

		#region methods
		void AddNode(_Key key, _Data data) { }
		void DelNode(_Key key, _Data data) { }
		public override string ToString()
		{
			string tokenName = this.GetType().Name;
			string keyName = typeof(_Key).Name;
			string dataName = typeof(_Data).Name;
			string toString = string.Format("{0}<{1},{2}>::{{", tokenName, keyName, dataName);
			toString += Common.GenericArrayToString<_Key>(Children.Keys.ToArray(), " ", ",", " ");
			toString += "}";
			return toString;
		}
		#endregion methods
	}
	public class HashTree<_Key, _Data>
	{
		#region ctors
		public HashTree() { _RootNode = CurrentNode = null; }
		public HashTree(HashTreeNode<_Key, _Data> rootNode) { _RootNode = CurrentNode = rootNode; }
		#endregion ctors

		#region properties
		public int Count { get { return 0; } }
		public HashTreeNode<_Key, _Data> RootNode { get { return _RootNode; } }
		public HashTreeNode<_Key, _Data> CurrentNode { get; set; }
		#endregion properties

		#region methods
		public void RevertCurrentToRoot()
		{
			CurrentNode = RootNode;
		}

		#endregion methods

		#region fields
		protected HashTreeNode<_Key, _Data> _RootNode;
		#endregion fields
	}
}
